<?php

use yii\db\Query;
use common\components\helpers\Fun;

$id = \Yii::$app->request->get('id');
if (isset($id)) {
    $customer_relationship = (new Query())->select('*')->from('{{%customer_relationship}}')->where(['id' => $id])->one(Fun::getSiteDb());
    if (isset($customer_relationship)) {
        $vice_responsibility_man = (new Query())->select('name')->from('{{%admin}}')
            ->where(['in', 'id', explode(',', $customer_relationship['admin_child_ids'])])->column(Fun::getSiteDb());
        $admin_child_ids = implode('/', $vice_responsibility_man);
    }
}
return [
    'id' => 'recoveryassign-form',
    'template' => 'form_default',
    'enableClientValidation' => false,
    'enableAjaxValidation' => true,
    'options' => ['class' => 'form-validate'],
    'models' => [
        'recoveryassign' => [
            'title' => '回收指派',
            'th_with' => 80,
            'elements' => [
                'admin_child_ids' => [
                    'type' => 'widget',
                    'class' => \kartik\select2\Select2::className(),
                    'data' => yii\helpers\ArrayHelper::map(\zhtfrontend\models\datas\Admin::find()->where(['status' => 1])->andWhere(['in', 'role', ['marketing_commissioner']])->all(), 'id', 'name'),
                    'options' => ['multiple' => true, 'placeholder' => empty($admin_child_ids) ? '请选择市场副负责人' : $admin_child_ids]
                ],
            ],
        ]
    ]
];
